﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BitPortal.Business;
using BitPortal.Models;
using BitPortal.Utils;

namespace BitPortal.Modules
{
    public partial class NewsDetail : Controls.BaseUserControl
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            Article_Comments.Visible = (bool) PortalConfigBLL.GetValueByName("Article.EnableComment");
            Article_Share.Visible= (bool) PortalConfigBLL.GetValueByName("Article.EnableShare");
            Article_Statistic.Visible = (bool) PortalConfigBLL.GetValueByName("Article.EnableStatistic");
            Article a = ArticleBLL.GetByID(Request.QueryString["ArticleID"].ToInt64TryParse());
            if (a == null) ExceptionHander.ThrowObjectNotFoundException();
            //Load content of article
            ltrTitle.Text = a.Title;
            ltrDescription.Text = a.Description;
            ltrContent.Text = a.Content;
            ltrNav.Text = a.ArticleCategory.Name;
            ltrDate.Text = ((DateTime)a.DatetimeDisplay).ToString("dd/MM/yyyy hh:mm");
            //Meta
            this.Page.MetaDescription = a.Meta.MetaDescription;
            this.Page.MetaKeywords = a.Meta.MetaKeyword;
            this.Page.Title = a.Meta.MetaTitle;
            //Comments
            this.ArticleComments.DiscusionGroupReference = a.DiscussionGroup;
            //Statistic
            this.Statistic1.CurrentStatistic = a.Statistic;
        }
    }
}